/**
 *
 * ......................我佛慈悲.......................
 *                       _oo0oo_
 *                      o8888888o
 *                      88" . "88
 *                      (| -_- |)
 *                      0\  =  /0
 *                    ___/`---'\___
 *                  .' \\|     |// '.
 *                 / \\|||  :  |||// \
 *                / _||||| -卍-|||||- \
 *               |   | \\\  -  /// |   |
 *               | \_|  ''\---/''  |_/ |
 *               \  .-\__  '-'  ___/-. /
 *             ___'. .'  /--.--\  `. .'___
 *          ."" '<  `.___\_<|>_/___.' >' "".
 *         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *         \  \ `_.   \_ __\ /__ _/   .-` /  /
 *     =====`-.____`.___ \_____/___.-`___.-'=====
 *                       `=---='
 *
 *..................佛祖开光 ,永无BUG....................
 *         CSDN博客:http://blog.csdn.net/song5347
 *       github地址:https://github.com/lingsuiderongyan
 *             邮箱:lingsuiderongyan@163.com
 */

import UIKit

class LSVisitorTableViewController: UITableViewController {
    
    //是否登录的标记
    var isLogin: Bool = LSUserAccountViewModel.sharedUserAccount.isLogin
    
    var visitorView: LSVisitorView?
    
    override func loadView() {
        
        //登录状态下使用系统提供的视图
        if isLogin {
            super.loadView()
        } else {
            
         //未登录视图,使用自己的定义访客视图
            visitorView = LSVisitorView()
            
            visitorView?.loginClosure = { [weak self] in
                
                
                self?.reqeustOAuthVC()
                
            }
            
            view = visitorView
            
            //设置导航栏按钮
            setNavUI()
        }
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    private func setNavUI() {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action: "registerAction")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self, action: "loginAction")
    }
    //MARK: - 点击事件
    @objc private func registerAction() {
        print("注册")
        reqeustOAuthVC()
    }
    
    @objc private func loginAction() {
        print("登录")
        reqeustOAuthVC()
    }
    
    //  登录第三方的函数
    private func reqeustOAuthVC() {
        
        let oAuthVC = LSOAuthViewController()
        let nav = UINavigationController(rootViewController: oAuthVC)
        presentViewController(nav, animated: true, completion: nil)
        
    }
}













